#@layout()

#define script()
<script>

    function doChangeStatus(id, status) {
        ajaxGet("#(CPATH)/admin/product/comment/doChangeStatus?id=" + id + "&status=" + status)
    }

    function doDel(id) {
        if (confirm("确定要删除这条评论吗？删除后不可恢复")) {
            ajaxGet("#(CPATH)/admin/product/comment/doDel/" + id);
        }
    }
</script>
#end

#define content()

    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                商品评论
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 商品 / 商品评论</small>
                            </h1>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-12" style="padding-top: 20px">
                            <a href="?">全部 (#(totalCount ??))</a> |
                            <a href="?status=normal">已发布 (#(normalCount ?? 0))</a> |
                            <a href="?status=unaudited">待审核 (#(unauditedCount ?? 0))</a> |
                            <a href="?status=draft">草稿 (#(draftCount ?? 0))</a> |
                            <a href="?status=trash" style="color: #a00">垃圾箱 (#(trashCount ?? 0))</a>
                        </div>
                    </div>

                </div>

            </div>

        </div><!-- /.container-fluid -->
    </section>



    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">
                    <div class="card-header with-border">

                        <form class=" admin-search-panel" action="" method="get">
                            <input type="hidden" name="status" value="#para('status')">
                            <div class="row">
                                <div class="form-group col-lg-2">
                                        <input type="text" placeholder="关键字" class="form-control" name="keyword" value="#para('keyword')">
                                </div>
                                <div class="form-group col-lg-8">
                                        <button type="submit" class="btn btn-primary ">搜索</button>
                                        <button type="reset" class="btn btn-default">重置</button>
                                </div>
                            </div>
                            <!-- /.card-body -->
                        </form>

                    </div>
                    <!-- /.card-header -->
                    <div class="card-body p-0">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 10px">
                                    <input class="tableCheckAll" id="checkall" type="checkbox"/>
                                </th>
                                <th style="width: 100px">作者</th>
                                <th style="width: 40%">内容</th>
                                <th>评论的产品</th>

                                <th style="width: 100px">状态</th>
                                <th>时间</th>
                            </tr>
                            #for(comment : page.list)
                            <tr>
                                <td><input name="tableItem" type="checkbox" value="#(comment.id)"/>
                                </td>
                                <td>
                                    <a href="#(CPATH)/admin/user/detail/#(comment.user.id ??)">
                                        #(comment.user.nickname ??)
                                    </a>

                                <td>
                                    #(comment.content ??)
                                    <strong>
                                        #if(comment.isUnaudited()) (待审核) #end
                                    </strong>
                                    <div class="jp-action-card">
                                        <div class="jp-action-body">
                                            <a href="#(CPATH)/admin/product/comment/edit/#(comment.id)">编辑</a> |
                                            <a href="#(CPATH)/admin/product/comment/reply/#(comment.id)">回复</a> |
                                            #if(comment.isNormal())
                                            <a href="javascript:;"
                                               onclick="doChangeStatus('#(comment.id)','2')">待审核</a> |
                                            #else
                                            <a href="javascript:;"
                                               onclick="doChangeStatus('#(comment.id)','1')">审核</a> |
                                            #end
                                            <a href="javascript:;" onclick="doChangeStatus('#(comment.id)','9')"
                                               class="red-action">垃圾箱</a> |
                                            <a href="javascript:;" onclick="doDel('#(comment.id)')"
                                               class="red-action">永久删除</a>

                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <a href="#(comment.product.url ??)" target="_blank">
                                        #(comment.product.title ??)
                                    </a>
                                </td>
                                </td>
                                <td>#(comment.statusStr ??)</td>
                                <td>#date(comment.created)</td>
                            </tr>
                            #else
                            <tr class="nodata"><td colspan="999">暂无数据</td> </tr>
                            #end
                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="row">

                                    <div class="form-group">
                                        <div class="form-check">
                                            <input class="form-check-input tableCheckAll" id="checkall" type="checkbox" >
                                            <label class="form-check-label" for="checkall">全选</label>
                                        </div>
                                    </div>
                                    <div class="form-group col-lg-3">
                                        <select class="form-control" name="action">
                                            <option value="">请选择...</option>
                                            <option value="doDelByIds" open-type="del-confirm">
                                                批量删除
                                            </option>
                                        </select>
                                    </div>

                                    <div class="form-group col-lg-3">
                                        <button type="button" class="btn btn-outline-primary batchExec">批量操作</button>
                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-6">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->
                </div>
                <!-- /.card -->
            </div>
    </section>
#end